//创建store

//导入创建store

import { configureStore, combineReducers } from "@reduxjs/toolkit";
//调用函数
import ticketReducer from "./slice/ticketSlice";
import userReducer from "./slice/userSlice";
import orderReducer from "./slice/orderSlice";
//数据持久化
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";

const persistConfig = {
  key: "root",
  storage,
  blacklist: ["order"],
};
const persistedReducer = persistReducer(
  persistConfig,
  combineReducers({
    //集成所有slice切片
    ticket: ticketReducer,
    user: userReducer,
    order: orderReducer,
  })
);

const store = configureStore({
  reducer: persistedReducer,
  middleware: (m) => m({ serializableCheck: false }),
});

export let persistor = persistStore(store);

//导出store
export default store;
